import { baseRequest } from '@/utils/request'

const request = (url, ...arg) => {
	return baseRequest(`/dashboard/dashboardlist/${url}`, ...arg)
}

/**
 * 获取仪表盘列表分页
 * @param {object} params - 分页参数
 * @returns {Promise}
 */
export const getDashboardPage = (params) => {
	return request('page', params, 'get')
}

/**
 * 添加仪表盘
 * @param {object} params - 仪表盘信息
 * @returns {Promise}
 */
export const addDashboard = (params) => {
	return request('add', params, 'post')
}

/**
 * 编辑仪表盘
 * @param {object} params - 仪表盘信息
 * @returns {Promise}
 */
export const editDashboard = (params) => {
	return request('edit', params, 'post')
}

/**
 * 删除仪表盘
 * @param {Array} params - 仪表盘ID列表
 * @returns {Promise}
 */
export const deleteDashboard = (params) => {
	return request('delete', params, 'post')
}

/**
 * 获取仪表盘详情
 * @param {object} params - 仪表盘ID
 * @returns {Promise}
 */
export const getDashboardDetail = (params) => {
	return request('detail', params, 'get')
}

/**
 * 获取仪表盘列表分页
 * @param {object} params - 分页参数
 * @returns {Promise}
 */
export const dashboardListPage = (params) => {
	return request('page', params, 'get')
}

/**
 * 添加仪表盘
 * @param {object} params - 仪表盘信息
 * @returns {Promise}
 */
export const dashboardListAdd = (params) => {
	return request('add', params, 'post')
}

/**
 * 编辑仪表盘
 * @param {object} params - 仪表盘信息
 * @returns {Promise}
 */
export const dashboardListEdit = (params) => {
	return request('edit', params, 'post')
}

/**
 * 删除仪表盘
 * @param {Array} params - 仪表盘ID列表
 * @returns {Promise}
 */
export const dashboardListDelete = (params) => {
	return request('delete', params, 'post')
}

/**
 * 获取仪表盘详情
 * @param {object} params - 仪表盘ID
 * @returns {Promise}
 */
export const dashboardListDetail = (params) => {
	return request('detail', params, 'get')
}

/**
 * 获取用户可访问的仪表盘列表
 * @returns {Promise}
 */
export const getUserAccessibleDashboards = () => {
	return request('userAccessible', {}, 'get')
}

export default {
	dashboardListPage,
	dashboardListAdd,
	dashboardListEdit,
	dashboardListDelete,
	dashboardListDetail,
	getUserAccessibleDashboards
}
